how to get the content of iframe in a php variable? [closed]

Posted by Sahil on Stack Overflow See other posts from Stack Overflow or by Sahil
Published on 2012-06-17T19:59:03Z Indexed on 2012/06/17 21:16 UTC
Read the original article Hit count: 128

Filed under:
|

My code is somewhat like this:

<?php

if($_REQUEST['post'])
{
    $title=$_REQUEST['title'];
    $body=$_REQUEST['body'];
    echo $title.$body;
}
?>

<script type="text/javascript" src="texteditor.js">
</script>

<form action="" method="post">
       Title: <input type="text" name="title"/><br>

       <a id="bold" class="font-bold"> B </a> 
       <a id="italic" class="italic"> I </a>

       Post: <iframe id="textEditor" name="body"></iframe>

       <input type="submit" name="post" value="Post" />
</form>

the texteditor.js file code is:

$(document).ready(function(){
document.getElementById('textEditor').contentWindow.document.designMode="on";
document.getElementById('textEditor').contentWindow.document.close();
$("#bold").click(function(){
 if($(this).hasClass("selected"))
 {
    $(this).removeClass("selected");
 }else
 {
    $(this).addClass("selected");
 }
 boldIt();
 });
 $("#italic").click(function(){

 if($(this).hasClass("selected"))
 {
  $(this).removeClass("selected");
  }else
  {
  $(this).addClass("selected");
  }
  ItalicIt();
  });


   });

   function boldIt(){
   var edit = document.getElementById("textEditor").contentWindow;
   edit.focus();
   edit.document.execCommand("bold", false, "");
   edit.focus();
   }

   function ItalicIt(){  
   var edit = document.getElementById("textEditor").contentWindow;
   edit.focus();
   edit.document.execCommand("italic", false, "");
   edit.focus();
   }

   function post(){
var iframe = document.getElementById("body").contentWindow;
    }

actualy i want to fetch data from this texteditor (which is created using iframe and javascript) and store it in some other place. i'm not able to fetch the content that is entered in the editor (i.e. iframe here).

please help me out of this....

© Stack Overflow or respective owner

Related posts about php

Related posts about html